<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>角色菜单管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
        content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="../../../layuiadmin/layui/css/layui.css" media="all">
</head>

<body>
    <div class="layui-form" lay-filter="layuiadmin-form-role" id="layuiadmin-form-role" style="padding: 20px 30px 0 0;">
        <fieldset class="layui-elem-field" style="margin-left:25px;min-height:300px">
            <legend>页面所属权限</legend>
            <div class="layui-field-box">
                <div class="layui-row">
                    <div class="layui-inline layui-col-xs4" style='float:left'>
                        <label class="layui-form-label">所有权限</label>
                        <div class="layui-input-block">
                            <input type="text" name="match" placeholder="请输入权限名" autocomplete="off" class="layui-input"
                                style="width:150px">
                        </div>
                    </div>
                    <div class="layui-inline layui-col-xs3">
                        <button class="layui-btn layuiadmin-btn-admin" lay-submit lay-filter="permissionQuery">
                            <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                        </button>
                    </div>
                    <div class="layui-inline layui-col-xs5">
                        <label class="layui-form-label">已选权限</label>
                    </div>
                </div>

                <div id='permissionList'></div>
            </div>
        </fieldset>
        <div class="layui-form-item layui-hide">
            <button class="layui-btn" lay-submit lay-filter="user-role-permission-submit"
                id="user-role-submit">提交</button>
        </div>
    </div>

    <script src="../../../layuiadmin/layui/layui.js"></script>
    <script>
        layui.config({
            base: '../../../layuiadmin/' //静态资源所在路径
        }).extend({
            index: 'lib/index' //主入口模块
            , my_send: '../myModules/my_send'
            , transfer_old: '../myModules/transfer_old'
        }).use(['index', 'form', 'transfer_old', 'my_send'], function () {
            var $ = layui.$
                , form = layui.form
                , http_proxy = layui.http_proxy
                , my_send = layui.my_send
                , transfer_old = layui.transfer_old;

            var params = location.search
                , urid = ''
                , menuId = []
                , data1 = []
                , data2 = []
                , tb1 = {};

            if (params && params !== '') {
                urid = params.substring(params.indexOf('=') + 1, params.indexOf('&'));
                menuId = params.substr(params.lastIndexOf('=') + 1).split(",");
            }

            form.on('submit(permissionQuery)', function (data) {
                //执行重载
                table.reload('roleTable', {
                    where: data.field
                });
            });

            //数据源
            my_send({
                url: '/menu/getNotHaveByMpidsAndUrid'
                , type: 'post'
                , data: {
                    mpids: menuId
                    , urid: urid
                }
                , success: function (obj) {
                    tb1 = transfer_old.render({
                        elem: "#permissionList", //指定元素
                        cols: cols, //表格列  支持layui数据表格所有配置
                        data: [obj.rows], //[左表数据,右表数据[非必填]]
                        tabConfig: tabConfig //表格配置项 支持layui数据表格所有配置
                    })
                    console.log(tb1.index);
                }
            })

            //表格列
            var cols = [
                { field: 'mpid', hide: true }
                , { type: 'checkbox', fixed: 'left' }
                , { field: 'pmName', title: '权限名称', unresize: true , width: "120" }
                , { field: 'parentName', title: '所属页面', unresize: true, width: "120"}
                , { field: 'pmComment', title: '描述', unresize: true, width: "300" }]
            //表格配置文件
            var tabConfig = { 'height': 400, }

        })
    </script>
</body>

</html>